package com.tfswue.lhj.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 应用配置属性类
 * 
 * @author daygods
 * @since 2025-07-09
 */
@Component
@ConfigurationProperties(prefix = "app")
public class AppProperties {
    
    /**
     * 应用名称
     */
    private String name = "SpringBoot Demo";
    
    /**
     * 应用版本
     */
    private String version = "1.0.0";
    
    /**
     * 应用描述
     */
    private String description = "SpringBoot示例应用";
    
    /**
     * 文件上传配置
     */
    private Upload upload = new Upload();
    
    /**
     * JWT配置
     */
    private Jwt jwt = new Jwt();
    
    /**
     * 缓存配置
     */
    private Cache cache = new Cache();
    
    /**
     * 文件上传配置类
     */
    public static class Upload {
        /**
         * 上传路径
         */
        private String path = "/uploads";
        
        /**
         * 最大文件大小（MB）
         */
        private int maxFileSize = 10;
        
        /**
         * 允许的文件类型
         */
        private String[] allowedTypes = {"jpg", "jpeg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx"};
        
        public String getPath() {
            return path;
        }
        
        public void setPath(String path) {
            this.path = path;
        }
        
        public int getMaxFileSize() {
            return maxFileSize;
        }
        
        public void setMaxFileSize(int maxFileSize) {
            this.maxFileSize = maxFileSize;
        }
        
        public String[] getAllowedTypes() {
            return allowedTypes;
        }
        
        public void setAllowedTypes(String[] allowedTypes) {
            this.allowedTypes = allowedTypes;
        }
    }
    
    /**
     * JWT配置类
     */
    public static class Jwt {
        /**
         * JWT密钥
         */
        private String secret = "mySecretKey";
        
        /**
         * JWT过期时间（小时）
         */
        private int expiration = 24;
        
        /**
         * JWT刷新时间（小时）
         */
        private int refreshExpiration = 168;
        
        public String getSecret() {
            return secret;
        }
        
        public void setSecret(String secret) {
            this.secret = secret;
        }
        
        public int getExpiration() {
            return expiration;
        }
        
        public void setExpiration(int expiration) {
            this.expiration = expiration;
        }
        
        public int getRefreshExpiration() {
            return refreshExpiration;
        }
        
        public void setRefreshExpiration(int refreshExpiration) {
            this.refreshExpiration = refreshExpiration;
        }
    }
    
    /**
     * 缓存配置类
     */
    public static class Cache {
        /**
         * 默认过期时间（秒）
         */
        private long defaultExpiration = 3600;
        
        /**
         * 缓存前缀
         */
        private String prefix = "app:cache:";
        
        /**
         * 是否启用缓存
         */
        private boolean enabled = true;
        
        public long getDefaultExpiration() {
            return defaultExpiration;
        }
        
        public void setDefaultExpiration(long defaultExpiration) {
            this.defaultExpiration = defaultExpiration;
        }
        
        public String getPrefix() {
            return prefix;
        }
        
        public void setPrefix(String prefix) {
            this.prefix = prefix;
        }
        
        public boolean isEnabled() {
            return enabled;
        }
        
        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getVersion() {
        return version;
    }
    
    public void setVersion(String version) {
        this.version = version;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public Upload getUpload() {
        return upload;
    }
    
    public void setUpload(Upload upload) {
        this.upload = upload;
    }
    
    public Jwt getJwt() {
        return jwt;
    }
    
    public void setJwt(Jwt jwt) {
        this.jwt = jwt;
    }
    
    public Cache getCache() {
        return cache;
    }
    
    public void setCache(Cache cache) {
        this.cache = cache;
    }
}